<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>商品查询列表</title>
    <%@ include file="/view/common/tags.jsp"%>
    <script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-body">
                    <div class="panel panel-default">
                        <div class="panel-body" style="padding-bottom:5px;">
                            <form class="form-horizontal" action="" method="post" id="dataForm">
                                <input type="hidden" id="token" name="token" value=""/>
                                <div class="searchMenu" >
                                    <div>
                                        <label>游戏：</label>
                                        <sk:select cssClass="form-control select" name="wm[GAME_ID]" id="gameId" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[USE_FLAG]=1" onchange="TagUtil.fillOptions('gameId')">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>游戏区：</label>
                                        <sk:select cssClass="form-control select" id="areaId" name="wm[AREA_ID]" value="${page.wm.AREA_ID}" ajaxURL="${userInfoV1}/baseArea/select?wm[USE_FLAG]=1&wm[DEL_FLAG]=1" parentCascadedSelect="gameId" parentParamName="gameId" onchange="TagUtil.fillOptions('areaId');" >
                                            <option id="area_id" value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>游戏服：</label>
                                        <sk:select cssClass="form-control select" id="serverId" name="wm[SERVER_ID]" value="${page.wm.SERVER_ID}" ajaxURL="${userInfoV1}/baseServer/select?wm[USE_FLAG]=1&wm[DEL_FLAG]=1" parentCascadedSelect="areaId" parentParamName="areaId">
                                            <option id="server_id" value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>商品类型：</label>
                                        <sk:select cssClass="form-control select" id ="goodsBigId" name="wm[GOODS_BIG_ID]" value="${page.wm.GOODS_BIG_ID}" onchange="TagUtil.fillOptions('goodsBigId');">
                                            <option value="">请选择</option>
                                            <option value="10">游戏币</option>
                                            <option value="11">装备</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>商品小类：</label>
                                        <sk:select cssClass="form-control select" id ="goodsSmallId" name="wm[GOODS_SMALL_ID]" value="${page.wm.GOODS_SMALL_ID}" parentCascadedSelect="goodsBigId" parentParamName="wm[TYPE_FLAG]" ajaxURL="${userInfoV1}/gameGoodsType/smallTypeSelect">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div class="searchMenu" >
                                        <div>
                                            <label>发布时间：</label>
                                            <input id="createTimeStart" name="wm[_MORE_EQUAL$GOODS_PUBLISH_TIME]" value="${page.wm._MORE_EQUAL$GOODS_PUBLISH_TIME}"  type="text"  class="Wdate"
                                                   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',alwaysUseStartDate:true,maxDate:'#F{$dp.$D(\'createTimeEnd\')}',minDate:'#F{$dp.$D(\'createTimeEnd\',{d:-30,H:-23,m:-59,s:-59})}'})" />
                                            <span class="pull-left">&nbsp;-&nbsp;</span>
                                            <input id="createTimeEnd" name="wm[_LESS_EQUAL$GOODS_PUBLISH_TIME]" value="${page.wm._LESS_EQUAL$GOODS_PUBLISH_TIME}"  class="Wdate"
                                                   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 23:59:59',alwaysUseStartDate:true,minDate:'#F{$dp.$D(\'createTimeStart\')}',maxDate:'#F{$dp.$D(\'createTimeStart\',{d:+30,H:+23,m:+59,s:+59})}'})" />
                                        </div>
                                        <div>
                                            <label>卖家账号：</label>
                                            <input id="sellAccount" name="wm[_LIKE$SELL_ACCOUNT]" value="${page.wm._LIKE$SELL_ACCOUNT}" type="text" class="form-control" />
                                        </div>
                                        <div>
                                            <label>商品状态：</label>
                                            <sk:select cssClass="form-control select" name="wm[GOODS_STATE]" id="goodsState" value="${page.wm.GOODS_STATE}" requiredInit="true" ajaxURL="${tradeV1}/tradeState/goodsStateDictList">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品来源：</label>
                                            <select class="form-control select" name="wm[GOODS_BASE_ITEM3]" id="goodsBaseItem3" value="${page.wm.GOODS_BASE_ITEM3}">
                                                <option value="">请选择</option>
                                                <option value="0">自有商品</option>
                                                <option value="10_DD373">DD373抓取</option>
                                                <option value="20_UU898">UU898抓取</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="mal10" >
                                        <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                        <thead>
                        <tr>
                            <th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
                            <th data-field="gameName" data-align="center" data-sortable="false">游戏信息</th>
                            <th data-field="areaName" data-align="center" data-sortable="false">游戏区</th>
                            <th data-field="serverName" data-align="center" data-sortable="false">游戏服</th>
                            <th data-field="goodsCode" data-align="center" data-sortable="false">商品编号</th>
                            <th data-field="goodsTitle" data-align="center" data-sortable="false" data-formatter="thirdGoodsFormatter_point">商品名称</th>
                            <th data-field="tradeName" data-align="center" data-sortable="true">交易类型</th>
                            <th data-field="goodsSmallName" data-align="center" data-sortable="true">商品小类</th>
                            <th data-field="publishPieceNum" data-align="center" data-sortable="true">发布件数</th>
                            <th data-field="remainNum" data-align="center" data-sortable="true">当前件数</th>
                            <th data-field="perPiecePrice" data-align="center" data-sortable="true">每件价格(元)</th>
                            <th data-field="goodsPublishTime" data-align="center" data-formatter="timeFormatter_point" data-sortable="true">发布时间</th>
                            <th data-field="sellAccount" data-align="center" data-sortable="false">卖家账号</th>
                            <th data-field="goodsState" data-align="center" data-formatter="goodsStateFormatter" data-sortable="true">商品状态</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<%@ include file="/view/common/footer.jsp"%>
</body>
<script>
    // 提示信息
    var msgg='<%=request.getAttribute("msg")%>';
    if (msgg && msgg!=null && msgg!='null') {
        layer.msg(msgg);
    }
    var tableIndex = 0; // 添加修改的弹出框的ID

    // 加载table 数据
    $(function(){
        $("#token").val(sessionStorage.getItem("token"));
        console.log("token = " + sessionStorage.getItem("token"));
        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/tradeGoods/data.json",
            method:"get",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })

    //查询
    function findData(){
        $("#dataTable").bootstrapTable("refresh",{} );
    }

    /*bootstrap table点击行事件*/
    $(function(){
        $("body").on("click","table>tbody>tr",function(){
            $(this).css("background","#e1ecf1").siblings().css("background","");
        });
    })

    // 商品状态
    function goodsStateFormatter(value, row) {
        var html = "";
        if (row.goodsState == 10) {
            html = "<span class='text-success'>上架中</span>";
        }else if (row.goodsState == 20){
            html = "<span class='text-warning'>待审核</span>";
        }else if (row.goodsState == 30){
            html = "<span class='text-warning'>待处理问题商品</span>";
        }else if (row.goodsState == 40){
            html = "<span class='text-warning'>下架中</span>";
        }else if (row.goodsState == 50){
            html = "<span class='text-warning'>已删除</span>";
        }else if (row.goodsState == 60){
            html = "<span class='text-warning'>已完成</span>";
        }else{
            html = "<span class='text-warning'>未知状态</span>";
        }
        return html;
    }
    
    // 第三方商品展示
    function thirdGoodsFormatter_point(value, row){
    	if(row.goodsBaseItem1 != undefined && row.goodsBaseItem1.indexOf("http") == 0){
    		return "<a href='" + row.goodsBaseItem1 + "' target='_blank'>" + value + "</a>"
    		+ " <span style='color:red;'>(" + row.goodsBaseItem3.substring(3) + ")</span>";
    	} else {
    		return value;
    	}
    }
</script>
</html>